import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import Antd, { ConfigProvider } from "ant-design-vue";
import "ant-design-vue/dist/reset.css";
import { setToken } from "@/utils/request";

//刷新时检查是否需要更新token
const token = sessionStorage.getItem("token");
if (token) {
  setToken(token);
}

//全局日期格式化方法
export const formattedDate = (timestamp: any) => {
  const date = new Date(timestamp);
  const year = date.getFullYear();
  const month = (date.getMonth() + 1).toString().padStart(2, "0");
  const day = date.getDate().toString().padStart(2, "0");
  const hour = date.getHours().toString().padStart(2, "0");
  const minute = date.getMinutes().toString().padStart(2, "0");
  const second = date.getSeconds().toString().padStart(2, "0");
  const formattedDate = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
  return formattedDate;
};

createApp(App).use(Antd).use(router).use(ConfigProvider).mount("#app");
